<template>
	<view :class="['page',{'iphoneX':isIphoneX}]">
		<template v-if="isLogin">
			<view class="body">
				
				<!-- 每日评价 -->
				<template>
					<view class="list-wrap">
						<template v-if="loadingState.default">
							<loading :loadingState="loadingState"></loading>
						</template>
						
						<template v-else>
							<template v-if="list.length>0"> 		 
								<navigator open-type="navigate" hover-class="none" :url="'/package_project/jl_pro/evaluateDetail/evaluateDetail?type='+type+'&id='+item.id" class="item" v-for="(item,index) in list" :key="index">
									<view class="pic">
										<image :src="img_path+item.file_path" mode="widthFix"></image>
										<view class="label">
											<image v-if="item.type==1" src="@/static/images/jl_eday.png" mode="widthFix"></image>
										</view>
									</view>
									<view class="info">
										<view class="name">
											<text :class="item.work_is_pass==1?'f-green':'f-red'">{{item.work_is_pass==1?'达标':'未达标'}}</text>
											<image v-if="item.work_is_pass==0" src="@/static/images/x.png" mode="widthFix"></image>
											<image v-if="item.work_is_pass==1" src="@/static/images/y.png" mode="widthFix"></image>
										</view>
										<view class="params">
											<view class="text">{{item.address}}</view> 
											<view class="text">评价时间：{{item.create_time}}</view> 
											<view class="text">监理意见：{{item.content}}</view> 
										</view>
									</view>
								</navigator> 
								
								<loading :loadingState="loadingState"></loading>
							</template>
							<template v-else>
								<empty msg="暂无信息"></empty>
							</template>
							
						</template> 
					</view> 
				</template>
				
	 
			</view>
 


		</template>
	</view>
</template>

<script>
	import {
		dateFormat,
		uploadImage,
		previewImage,
		uploadToServe
	} from '@/common/util.js' 
	import {img_path} from '@/config.js'
	import loading from '@/components/loading-more.vue'
	import empty from '@/components/empty.vue'
	export default {
		name: 'name',
		data() {
			return {
				isLogin: true,
				isIphoneX: getApp().globalData.isIphoneX,
				userInfo: uni.getStorageSync('userInfo'),
				isStop: true,
				type: '',  
				loadingState:{
					default:true,
					loading:false,
					compelted:false
				}, 
				list:[],
				params: {
					pid:'',
					uid:'',
					page:1,
					pao_type:'',   // 1 防控  2 监测  3 监理
					memberInfo:0,
					type:'',   // all 全部数据  user 用户数据
					data_type:''   // fk 防控  fx 防效 
				},
				img_path:img_path
			}


		},
		async onLoad(params) {
			this.type=params.type;
			this.params.pid=params.pid;
			this.params.type=params.datatype,
			this.isLogin = await this.$loginState('check');
			
			if(this.type=='day'){
				uni.setNavigationBarTitle({
					title:"每日评价数据"
				})
			}else if(this.type=='stage'){
				uni.setNavigationBarTitle({
					title:"阶段评价数据"
				})
			}

			if (this.isLogin) { 
				this.getList();
			}
		},
		async onShow() {

		},
		onReachBottom(){
			if(this.loadingState.completed){ 
				this.params.page=1;
				return false
			}else{
				if(this.list.length<this.total&&this.list.length>0){
					this.params.page++;
					this.getList()
				} 
				
			}	 
		},
		methods: {
			
			getList:async function(){
				let res=await this.$api.pro_api.jlprodatalist({
					pid: this.params.pid,
					uid: this.userInfo.id,
					page: this.params.page,
					type: this.type=='day'?1:2,
					type_code: 'jl_pj_data',
					dataRange: this.params.type,
					is_app:1
				})   
				if(res.data.ret==0){
					this.loadingState.default=false;
					this.loadingState.loading=true;
					this.total=res.data.data.count;
					this.list=this.list.concat(res.data.data.list);
					if(this.list.length==res.data.data.count){
						this.loadingState.loading=false;
						this.loadingState.completed=true;
					} 
				}else{
					this.loadingState.default=false; 				
				}
			} 
			
			 

		},
		components: {
			loading,
			empty
		},

		computed: {
			list_update(){ 
				return this.$store.state.evaluateListUpdate;
			}
		},
		watch: {
			list_update(newer,older){ 
				if(newer!=older){
					this.list=[];
					this.params.page=1;
					this.loadingState.default=true;
					this.loadingState.loading=false;
					this.loadingState.completed=false;
					this.getList();
				}
			}
		}

	}
</script>

<style lang="less" scoped>
	.list-wrap{
		padding-top:20rpx;
		.item{ 
			display: flex;
			padding:20rpx;
			margin-bottom: 20rpx;
			background:#fff;
			.pic{
				position:relative;
				width:30%;
				display: flex;
				align-items: center;
				height: 200rpx;
				margin-right: 20rpx;
				overflow: hidden;
				flex-shrink: 0;
				border:1rpx solid #eee;
				.label{
					position: absolute;
					right:0;
					top:0;
					width: 80rpx;
				}
				image{
					width: 100%;
				}
			}
			.info{
				flex-grow: 2;
				.name{
					display: flex;
					align-items: center;
					margin-bottom: 10rpx;
					font-size: 32rpx;
					image{
						width: 32rpx;
						margin-left: 10rpx;
					}
				}
				.params{
					font-size:30rpx;
					color:#999;
					.text{
						margin-bottom:8rpx;
					}
				}
			}
		}
	}
 
</style>
